Exact sampling for the Ising model