Efficient optimization method for finding minimum energy paths of magnetic transitions