write_file: add pointer+len variant