Because the system does work on the surrounding(the piston is pushed up), the internal energy (energy of motion of the molecules and potential energy stored in chemical bonds and position) and temperature of the system decrease. However, the temperature and change in internal energy remain constant because heat from the thermal reservoir replenishes the lost of heat due to work. Knowing that the energy lost due to work is equal to the heat gained, it is possible to calculate the heat that is gained by the system if we know how much work is done (this is just the area under the curve from V1 to V 2)