Search for resonances in the mass spectrum of muon pairs produced in association with b quark jets in proton-proton collisions at sqrt(s) = 8 and 13 TeV