Windows compatibility: uses TEMP from env

If TMPDIR doesn't exist, try TEMP before defaulting to '/tmp'

On Windows, %TEMP% points to the temporary directory (usually %HOMEPATH%\AppData\Local\Temp).