def cleanup(self):
        """Cleanup: ensure image closed and remove temporary output file."""
        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))
Cleanup: ensure image closed and remove temporary output file.