Measurement of b hadron lifetimes in pp collisions at $\sqrt{s} =$ 8 TeV