Duality for the general isomonodromy problem