The partition function of the two-matrix model as an isomonodromic τ function