Bayern Munich came from behind to beat Hertha Berlin 3-2 at the Allianz Arena and maintain their place at the top of the Bundesliga.