the question is, how did he get there so fast? It takes some time to muster an army, even an Elvish one, and it's a bit of a trip from Mirkwood and they got there in full battle array in time to see dwarves fleeing out the front gate. That's pretty speedy travel unless they had advance warning of some kind. Or a teleport. Or just happened to already be in the neighborhood...in full armor.

Based on what Tolkien wrote and using Fonstad's The Atlas of Middle-earth, I have to conclude that it should have taken King Thranduil one day to muster and prepare a force, and at least three days to march from Mirkwood directly to Erebor. The movie scene just doesn't work when one is aware of the logistics involved. 'There are older and fouler things than Orcs in the deep places of the world.' - Gandalf the Grey, The Fellowship of the Ring