Aberdeen’s Premiership goal drought came to an end when Sam Cosgrove, Ryan Hedges and Greg Leigh led the team to their biggest Scottish Premiership win since January.