From Average-Iterate to Last-Iterate Convergence in Games: A Reduction and Its Applications