Extracted two methods from file_write().

Created new static methods copy_file() and write_bytes().