Fix imports and reformat io.py