England secured a four-wicket win over Australia in just two days to avoid a whitewash in the Ashes series.