Some python3 compatibility fixes (close #220).