Save temp file in binary mode (fix for Windows)

[Finishes #50910193], closes #27