amberc.js: resolve undefined variable error
amberc.js: use basename in resolve_js()
amberc.js: fix async error in resolve_libraries()

If Combo.add() is evaluated immediately a function
it can lead to a double evaluation of Combo.callback.
In this case the Combo counter gets incremented and decremented
before another instance of Combo.add() can be created.
amberc.js: always evaluate the callback in compile()
amberc.js: always evaluate callback in async_map

even if array is empty
amberc.js: add missing fileStream.end() calls
amberc.js: checks against length instead of undefined
amberc.js: call optimize() after file is written completely to disk