Tailoring the emission of terahertz quantum cascade lasers