Measurement of top quark-antiquark pair production in association with a W or Z boson in pp collisions at sqrt(s) = 8 TeV