`binmode` makes the tempfile binary. Without it, you'll get encoding errors when it tries to write from an incompatible file format.