def METHOD_NAME(self, obj):
    """Wraps the output stream, encoding Unicode strings with the specified encoding"""
    if isinstance(obj, str):
        obj = obj.encode(self.encoding)
    self.out.buffer.METHOD_NAME(obj)