The phase transition and phase stability of magnetoelectric BiFeO3