Some fixes to make Python generation work. Use io.open again.