fix import and name errors for python3