win32 compatible temp file handling (thanks, Gábor Oláh https://github.com/olikasg)