Iterative method for predistortion of MRI gradient waveforms