Improved binary mode setting for stdin/stdout on Windows