Rory McIlroy overturned a three shot final round deficit to squeeze past South Africa's Louis Oosthuizen and win the Deutsche Bank Championship by one stroke.