Harry has to survive the Dementors in order to travel back in time to save himself from the Dementors. Yeah. Think about it.
http://www.mjyoung.net/time/potter.html
This dude lays out what could have happened and it makes a weird sense but holy craaaaap is it complicated
Summary: Timeline A: Harry Potter Dies from Werewolf, Buckbeak Dies, Sirius Dies, Shit. Sucks.
Timeline B: Buckbeak lives, everyone else still dies
Timeline C: Buckbeak Lives, Hermione casts Patronus, saves Harry/Sirius
Timeline D: Harry goes back with Hermione, casts Patronus, everyone lives
Timeline E: Same as above but now Timeline D Harry that was being attacked thinks his father saved him so goes looking for him but then realizes he did it and already did it and everyone lives.