How is the temperature of a substance affected as it undergoes a change of state?