Improve temporary file generation