docs: def encode(data, version=0, level=QR_ECLEVEL_L, hint=QR_MODE_8,
             case_sensitive=True):
      """Creates a QR-Code from string data.
      
      Args:
        data: string: The data to encode in a QR-code. If a unicode string is
            supplied, it will be encoded in UTF-8.
        version: int: The minimum version to use. If set to 0, the library picks
            the smallest version that the data fits in.
        level: int: Error correction level. Defaults to 'L'.
        hint: int: The type of data to encode. Either QR_MODE_8 or QR_MODE_KANJI.
        case_sensitive: bool: Should string data be encoded case-preserving?
      Returns:
        A (version, size, image) tuple, where image is a size*size PIL image of
        the QR-code.
      """
      if isinstance(data, unicode):
          data = data.encode('utf8')
      elif not isinstance(data, basestring):
          raise ValueError('data argument must be a string.')
      version = int(version)
      if level not in levels:
          raise ValueError('Invalid error-correction level.')
      if hint not in hints:
          raise ValueError('Invalid encoding mode.')
      if case_sensitive:
          version, size, data = _encode(data, version, level, hint, True)
      else:
          version, size, data = _encode(data, version, level, hint, False)
      
      im = Image.frombytes('L', (size, size), data)
      return (version, size, im)