Teaching Language Models to Hallucinate Less with Synthetic Tasks