Change / to // (integer division) in several places

This fixes a bunch of bugs and test failures in Python 3, which uses "true division" for /