If the tempDir is not writable, try the system's global cache dir

This fixes #51
Why not always use `sys_get_temp_dir()`?