Theory of Quantum Annealing of an Ising Spin Glass