Might be worth referencing [the recipe](http://code.activestate.com/recipes/65443-sending-binary-data-to-stdout-under-windows/) since presumably this code was copied from there.