Thermoelectricity in molecular junctions with harmonic and anharmonic modes