extract.py: updated for python3 compatability