Three-dimensional Model of the Structure and Evolution of Coronal Mass Ejections