Pickle obj to file_name.

def serialize_to_file(obj, file_name, append=False):
  """Pickle obj to file_name."""
  logging.info("Serializing to file %s.", file_name)
  with tf.gfile.Open(file_name, "a+" if append else "wb") as output_file:
    pickle.dump(obj, output_file)
  logging.info("Done serializing to file %s.", file_name)