Tau functions and Hamiltonians of isomonodromic deformations