I read in a textbook that in the case when we have a gas in a cylinder fitted with a massless frictionless piston being held with an external pressure $p_1$, and when the pressure is reduced to become the value $p_2$, the gas pushes up against the piston and then the work done by the gas for a small change in volume is calculated by:
$$\mathrm dW=p_2\,\mathrm dV$$
Here, is what I don't conceptually understand. If the gas's molecules was under some pressure $p_1$ which is equal to the external pressure in the static state then after the external pressure became lower than the internal pressure, shouldn't the work done by the gas be the difference between the two pressures?