Chain-of-Thought Matters: Improving Long-Context Language Models with Reasoning Path Supervision