Controlling the energy flow in nonlinear lattices: A model for a thermal rectifier