Search for pair production of third-generation scalar leptoquarks and top squarks in proton-proton collisions at sqrt(s) = 8 TeV