when youre fighting a legendary, save before you actually fight it, that goes the same for bos battles, and the elite four. AAnd never save while in the elite four too. If youre having trouble on legenddaries, put them to sleep, it helps a lot.
ALways make sure you have around 30 ultra balls with you.
if you need more help, check out the actual glitch topic. Although this glitch doesnt always work, it passes 90% of the time.