Scotland kept their Rugby World Cup quarter-final hopes alive with a 45-17 Pool B bonus-point victory over Tonga in Nice.