use temp file binary mode