A late header from Gareth Bale kept Real Madrid's La Liga title challenge alive as they battled to a 1-0 win at Real Sociedad on Saturday.