Replaced hardcoded UNIX-only tmpfile with a cross-platform Python tempfile.