code: def write(self, filename=None):
          
          if filename is None:
              filename = self._filename
  
          exif_bytes = piexif.dump(self._ef)
  
          with open(self._filename, "rb") as fin:
              img = fin.read()
          try:
              piexif.insert(exif_bytes, img, filename)
  
          except IOError:
              type, value, traceback = sys.exc_info()
              print >> sys.stderr, "Error saving file:", value
docs: Save exif data to file.