code: def cleanup(self):
          
          if self.image:
              try:
                  self.image.close()
              except Exception:
                  pass
          if (self.outtmp is not None):
              try:
                  os.unlink(self.outtmp)
              except OSError as e:
                  self.logger.warning("Failed to cleanup tmp output file %s"
                                      % (self.outtmp))
docs: Cleanup: ensure image closed and remove temporary output file.