Use sys.stdout.buffer instead of sys.stdout

sys.stdout defaults to text mode, we need to use the underlying buffer
instead when writing binary data.

Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Merge pull request #762 from jynnantonix/master

Use sys.stdout.buffer when writing to standard out