On the cohomological equation of magnetic flows