893368 - set output encoding when stdout is not a tty

This fix is to prevent the following python error from happening:

ERROR: 'ascii' codec can't encode character u'\u201c' in position 275:
ordinal not in range(128)