Aberdeen all but secure second spot in the Premiership with victory over 10-man Hearts at Tynecastle.