Py3 fixes

s/xrange/range/. Convert to int. 

Makes it work on Python3. Apparently Travis doesn't check numpy on Py3.