Fix the encoder and Part class for Python 3