England keep their Ashes hopes alive by beating Australia by three wickets in another nerve-shredding Headingley finale.