On one point, your comment that greater mass of the molecule is responsible does not sound right to me. CO2 and water molecules have dipoles, (O-C-O being - + - and H-O-H being + - + ) which will couple to the electric vector of radiation at characteristic frequencies, determined by the resonance frequencies of the stretching and bending of their chemical bonds. As a result they both absorb in the IR. By contrast, O2 and N2 have no dipoles and are therefore transparent in the IR.
So what happens is sun light of all wavelengths warms the ground, which then re-radiates predominantly in the IR and some of this gets absorbed by water and CO2 instead of being radiated directly out into space.
(The molar specific heats of gases are not a function of their molecular weight, but depend on the number of degrees of freedom the molecule has to take up energy. For monatomic gases, which can't rotate and have only 3 translational degrees of freedom, it is 3/2RT. For diatomic gases, which can rotate in 2 dimensions as well, it is 5/2RT.)