Practice riding faster, then you'll be able to out run them most of the time

Towards the end of a long ride, not so much. I carry pepper spray, just in case, haven't had to use it yet. Before I started carrying spray, I was forced to get off my bike (busy highway, no shoulder) and a pair of demon possessed dogs came out of nowhere, complete with red eyes. I just walked on the other side of my bike. Makes a great barrier/weapon. Some dogs can be scared just by the bike + you yelling, others, just keep walking and keep them on the other side of your bike until you can ride away.
Carrying dog treats = bad idea (Friend of mine did, oops) They'll chase you even more, especially if you frequent the route!