Search for pair production of first and second generation leptoquarks in proton-proton collisions at sqrt(s) =8 TeV