Lifetime measurements for excited states of rare-earth atoms using pulse modulation of a cw dye-laser beam