fixed some python 3 bugs.