improved write_file in amd64 mode