code: def safe_write(filename, blob):
      
      temp_file = filename + '.saving'
      with open(temp_file, 'bw') as f:
          f.write(blob)
      os.rename(temp_file, filename)
docs: A two-step write.
      :param filename: full path
      :param blob: binary data
      :return: None