Import StringIO from proper module for sys.version
Remove tests of private methods
Write bytes to out, since 3.x buffer interface does not support strings
Add get_json_as_unicode function