Very strong magnetic fields are created by spectator nucleons at early times in non-central heavy-ion collisions at ultrarelativistic energies. This strong magnetic field is believed to drive anomalous transport effects like chiral magnetic effect in heavy ion collisions. At ultrarelativistic energies, a quark gluon plasma medium is expected to be formed within less than 1 fm/c time. This conducting medium can capture a fraction of the initial magnetic field which can then survive in the plasma for a few fm/c. We study the effect of magnetic field in the hydrodynamic evolution of the plasma using 3+1 ideal relativistic magnetohydrodynamic simulations. Our results show that the magnetic field leads to enhancement of elliptic flow in non-central collisions. We see that very strong magnetic fields result in an even-odd difference in the power spectrum of flow fluctuations. Interestingly, we also find that magnetic field in localized regions can temporarily increase in time as the evolving plasma energy density fluctuations lead to reorganization of magnetic flux. This can have important effects on the chiral magnetic effect. We also discuss the situation of nontrivial magnetic field configurations arising from collision of deformed nuclei and show that it can lead to anomalous flow.