Phase transitions and lattice dynamics in Ag2H3IO6 and (NH4)2H3IO6