Fix py2.6 unicode output test cases

The behavior of streams with an '.encoding' parameter changed
from 2.6 to 2.7: writing unicode is not allowed in 2.6, but
is in 2.7. In 3.x, the latter is the standard behavior.

At least, for stdin/stdout. We can also have a binary file
stream, in which case we have to decide the encoding ourselves.

Change-Id: I29118b548ef95544d0f6a148d76bae109e9cfbe5
Merge "Fix py2.6 unicode output test cases"