Fixes stdout --sql output in python2

When output_encoding is set, wraps the output buffer into a io.TextIOWrapper class
This means that the output_buffer has to be a io.IOBase instance
in order to work along with the TextIOWrapper

Handles wrapping when the buffer is Python2 stdtout, which has 'file' type
Adds test for this situation
Fixes to Py3k in-place compatibity regarding output encoding and related;
the use of the new io.* package introduced some incompatibilities on Py2k.
These should be resolved, due to the introduction of new adapter types
for translating from io.* to Py2k file types, StringIO types.
Thanks to Javier Santacruz for help with this.
Merge branch 'fix_python2_sql_output'

Conflicts:
	docs/build/changelog.rst