add simple JSON output support for PHP lower than 5.4.0
add utf8 support for output