Dogs normally only have a single master apiece, so there should be no confusion (which is the important consideration) with either of your sentences. However, I would use the first one in order to maintain the parallel of 'dogs' - 'masters'.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.