A thermodynamically consistent formulation of the pseudo-incompressible equations for atmospheric modelling with an extension to moist processes