Deforming Galois representations and the conjectures of Serre and Fontaine-Mazur