Fix Windows line-ending issues

On Windows, any newlines printed to $stdout are automatically converted
to "\r\n", which breaks the protocol buffer format.  Switching $stdout to
binary mode immediately before printing the file prevents this from
happening.