Patch from Maciej Adamczyk to set standard output to binary mode in