Default encoding to utf-8 when "None" is found

It would appear that if the encoding property is set on self.stream, but
it is set to None, then we get msg.encode(None, 'replace') which causes
an error to be printed by the logging framework.