Python 3 support, fixed #344.