Fix writing native kernel spec on Python 2