Goals in either half from Jonny Hayes and Willo Flood helped Aberdeen to a 2-1 win over Kilmarnock at Pittodrie.