docs: def encode(name, values, strict=True, encoding=pyamf.AMF0):
      """
      Produces a SharedObject encoded stream based on the name and values.
  
      @param name: The root name of the SharedObject.
      @param values: A `dict` of name value pairs to be encoded in the stream.
      @param strict: Ensure that the SOL stream is as spec compatible as possible.
      @return: A SharedObject encoded stream.
      @rtype: L{BufferedByteStream<pyamf.util.BufferedByteStream>}, a file like
          object.
      """
      encoder = pyamf.get_encoder(encoding)
      stream = encoder.stream
  
      # write the header
      stream.write(HEADER_VERSION)
  
      if strict:
          length_pos = stream.tell()
  
      stream.write_ulong(0)
  
      # write the signature
      stream.write(HEADER_SIGNATURE)
  
      # write the root name
      name = name.encode('utf-8')
  
      stream.write_ushort(len(name))
      stream.write(name)
  
      # write the padding
      stream.write(PADDING_BYTE * 3)
      stream.write_uchar(encoding)
  
      for n, v in values.iteritems():
          encoder.serialiseString(n)
          encoder.writeElement(v)
  
          # write the padding
          stream.write(PADDING_BYTE)
  
      if strict:
          stream.seek(length_pos)
          stream.write_ulong(stream.remaining() - 4)
  
      stream.seek(0)
  
      return stream