Modular exponentiation implementation in Python, though Python has its own modular exponentiation function :(