code: def create_tempfile
        tempfile = Tempfile.new(["image_processing", ".#{destination_format}"], binmode: true)
  
        yield tempfile
  
        tempfile.open
        tempfile
      rescue
        tempfile.close! if tempfile
        raise
      end
docs: Creates a new tempfile for the destination file, yields it, and refreshes
   the file descriptor to get the updated file.