Gregor Townsend admits Japan deserved to beat Scotland as his side exited the World Cup at the pool stages.