Aberdeen earned their second win of the week against bottom club St Mirren thanks to goals from Stevie May and Sam Cosgrove.