Transition from fireball to Poynting-flux-dominated outflow in the three-episode GRB 160625B