Add functions to generate temp file name, and write bytes into files.