Dev stats log api v1.6

Rebased version of https://github.com/inliniac/suricata/pull/1200, with following addition:
- address issue of buffer being too small for large number of threads

This PR adds:
- Introduces an output API for Stats
- Converts existing stats.log output to this API
- Add Lua support for this API (https://redmine.openinfosecfoundation.org/issues/1309)

Prscript:
- PR build: https://buildbot.openinfosecfoundation.org/builders/inliniac/builds/66
- PR pcaps: https://buildbot.openinfosecfoundation.org/builders/inliniac-pcap/builds/66