Fix type error on python3: 'float' object cannot be interpreted as an integer.