Cook hundred for Essex but Gloucestershire fight back on Day 2