code: def do_format(self, format):
          
          fmt = ('jpg' if (format is None) else format)
          if (fmt == 'png'):
              self.logger.debug("format: png")
              self.mime_type = "image/png"
              self.output_format = fmt
              format = 'png'
          elif (fmt == 'jpg'):
              self.logger.debug("format: jpg")
              self.mime_type = "image/jpeg"
              self.output_format = fmt
              format = 'jpeg'
          elif (fmt == 'webp'):
              self.logger.debug("format: webp")
              self.mime_type = "image/webp"
              self.output_format = fmt
              format = 'webp'
          else:
              raise IIIFError(code=415, parameter='format',
                              text="Unsupported output file format (%s), only png,jpg,webp are supported." % (fmt))
          if (self.outfile is None):
              # Create temp
              f = tempfile.NamedTemporaryFile(delete=False)
              self.outfile = f.name
              self.outtmp = f.name
              self.image.save(f, format=format)
          else:
              # Save to specified location
              self.image.save(self.outfile, format=format)
docs: Apply format selection.
  
          Assume that for tiling applications we want jpg so return
          that unless an explicit format is requested.