Update key2pub.py

Remove deprecated syntax to make it compatible with Python 3.