bugfix: ngx_http_lua_chain_get_free_buf(): avoided returning zero-sized memory bufs.
fixed 2 minor lua stack manipulation mistakes.
bugfix: rewrote the buggy patch in commit 4c215c556 for #386 because it did not handle flush bufs correctly and had other issues.