This is the classic integer division problem with python2issue
In python2 temp /= 64 would perform integer division and so would result in truncated integer value. But your code would work fine. But it in python3 as the division, this would result in a floatfloat.
To fix itthe issue in python2python3, change temp /= 64 to temp //= 64.0, so that you would to force gettinginteger division and get rid of the result as a floattemp = int(temp) line