docs: def do_format(self, format):
          """Apply format selection."""
          infile = self.tmpfile
          outfile = self.basename + '.out'
          outfile_jp2 = self.basename + '.jp2'
          # Now convert finished pnm file to output format
          # simeon@ice ~>cat m3.pnm | pnmtojpeg  > m4.jpg
          # simeon@ice ~>cat m3.pnm | pnmtotiff > m4.jpg
          # pnmtotiff: computing colormap...
          # pnmtotiff: Too many colors - proceeding to write a 24-bit RGB file.
          # pnmtotiff: If you want an 8-bit palette file, try doing a 'ppmquant 256'.
          # simeon@ice ~>cat m3.pnm | pnmtopng  > m4.png
          fmt = ('png' if (format is None) else format)
          if (fmt == 'png'):
              # print "format: png"
              if (self.shell_call(self.pnmtopng + ' ' + infile + ' > ' + outfile)):
                  raise IIIFError(
                      text="Oops... got nonzero output from pnmtopng.")
              mime_type = "image/png"
          elif (fmt == 'jpg'):
              # print "format: jpg"
              if (self.shell_call(self.pnmtojpeg + ' ' + infile + ' > ' + outfile)):
                  raise IIIFError(
                      text="Oops... got nonzero output from pnmtojpeg.")
              mime_type = "image/jpeg"
          elif (fmt == 'tiff' or fmt == 'jp2'):
              # print "format: tiff/jp2"
              if (self.shell_call(self.pnmtotiff + ' ' + infile + ' > ' + outfile)):
                  raise IIIFError(
                      text="Oops... got nonzero output from pnmtotiff.")
              mime_type = "image/tiff"
              if (fmt == 'jp2'):
                  # use djatoka after tiff
                  if (self.shell_call(DJATOKA_COMP + ' -i ' + outfile + ' -o ' + outfile_jp2)):
                      raise IIIFError(
                          text="Oops... got nonzero output from DJATOKA_COMP.")
                  mime_type = "image/jp2"
                  outfile = tmpfile_jp2
          else:
              raise IIIFError(code=415, parameter='format',
                              text="Unsupported output file format (%s), only png,jpg,tiff are supported." % (fmt))
          self.outfile = outfile
          self.output_format = fmt
          self.mime_type = mime_type