Cast keys to a list for Python 3 compatibility.