The question asks if Tom was there when you arrived.
Your answer "No, he was going home" contains an innate illogicality since at the same time you are denying he was there and stating he was there though about to leave. Therefore if you answer with the word "No", it has to be "he had gone".
You could answer "Yes, but he was just going home".
Student or Learner