Fix binary mode stdio on Windows

See https://code.activestate.com/recipes/65443-sending-binary-data-to-stdout-under-windows/