Modeling and improving the output power of terahertz master-oscillator power-amplifier quantum cascade lasers.