Replaced os.tempnam
Fixed a potential issue where binary files could get corrupted on Windows