core: fix stdout()/stderr() helpers for Python 3

On Python 3, the core.stdout() and core.stderr() helper functions were
attempting to concatenate the message encoded as a bytestring with a
unicode string containing a newline, which raises a TypeError.  Fix this
by concatenating the newline first, and then only encoding the result if
on Python 2, since Python 3 wants unicode strings anyway.

Signed-off-by: Daniel Harding <dharding@living180.net>
Merge pull request #254 from living180/py3_fix_stdout_stderr

Fix stdout()/stderr() helpers for Python 3