Provably Convergent Algorithms for Solving Inverse Problems Using Generative Models