Search for top-squark pairs decaying into Higgs or Z bosons in pp collisions at sqrt(s) = 8 TeV