Standardize JSON output

json_encode options that we should use for editable json output (like composer.json) are only available on PHP 5.4 and above. This borrows the same routine used in composer, so that we get consistent easily editable 'pretty printed' output under all PHP versions.
Several small fixes, including xcaptcha form issue
Merge pull request #207 from geekwright/json

Standardize JSON output
Merge pull request #208 from geekwright/fixes

Several small fixes, including xcaptcha form issue
Fix to earlier fix :(

Somehow, the last change to this file was not what was intended (or tested.)
Merge pull request #209 from geekwright/fixfix

Fix to earlier fix :(