Work around Windows problems with temporary directories

Hmpf. Windows. Windows is a little different than every normal operating system. Just a little, just different enough to require extra attention. Windows is special. And Windows takes the special bus, once again.

Still needs testing on Windows (which the primary reason to open a PR that I'll probably merge right away, once the testing shows that it works).