fix metaclass compatibility between py2 and py3