Use of intracavity filters for optimization of far-infrared free-electron lasers