The light will eventually reach galaxy B even though the space between them is expanding. It is important to remember that it is the space that is expanding not galaxy B moving away from galaxy A. Imagine putting two dots on a balloon and blowing it up. It is the rubber between the dots that is stretching, not one dot moving about the balloon's surface away from the other dot.
Imagine a photon of light leaving galaxy A. After a period of time it will have travelled some distance towards galaxy B. Let's say it has travelled 1% of the distance so it has 99% to go. Space is expanding equally in front of and behind the photon, so even if it were to stop moving it would stay at 1% of the total distance. But it doesn't stop, it moves nearer. It will eventually get half way and again the space is expanding both behind and in front of the photon. Now there is the same amount of space in between the photon and galaxy A as there is between the photon and galaxy B. No matter how much expansion there is the photon is still in the middle. Eventually the photon will get all the way to galaxy B.
No matter how fast the universe is expanding and how slow the photon is moving it will eventually reach galaxy B although it may take a very very long time.
As the space the photon is in is expanding the wavelength of the photon will slowly change. This is red shift.
Now for the problem with this answer. I believe this answer is only valid if the speed of the expansion and the speed of the photon is constant, but the expansion of the universe appears to be accelerating.