Split error handling into two functions

Splits the actual error message generator into json_last_error_msg(),
which has full compatibility with PHP 5.5's function.

Note: error messages updated to match PHP source; see
https://github.com/php/php-src/blob/b2d2b965b2ddb2e013a15a8858420f18614562a9/ext/json/json.c#L840-L872