docs: def as_binary(self, content, encoding='utf8'):
          '''Perform content encoding for binary write'''
          if hasattr(content, 'read'):
              return content.read()
          elif isinstance(content, six.text_type):
              return content.encode(encoding)
          else:
              return content