Change tempfile mode to w rather than w+b.