def write(self, stream, message):
if isinstance(message, bytes):<EOL><INDENT>message = message.decode('<STR_LIT:utf-8>')<EOL><DEDENT>stream.write(message)<EOL>
write will write a message to a stream,
        first checking the encoding