After Naruto has performed Talk No Jutsu on Sasuke, they will unite to fight Madara... when they will do this, Madara will eventually see that they are able to break the chain of hatred and will do a favor before dying, just like Pain did... thus, instead of placing the world under an illusion of peace, Madara will use his power to make everyone forget the evil deeds of Sasuke in order to give him and Naruto another chance to change the world...
Don't ask me my sources, this is pure randomness U_U