Fix code for python 3