tempfile only needs to be opened with wb, not w+b