some python3 fixes for keymatrix.py