Ensure tmp file is written in binary mode, and do not assume it is PDF