Update for Python 3 compatible codebase

Requires sympy/sympy#2318