Gain measurement of terahertz quantum cascade laser via a master-oscillator power-amplifier configuration