Only return debug information if user wants it

As @holic pointed out, the unencoded debug information causes problems for
json_encode() as it assumes all strings are UTF-8 encoded. Instead of
trying to 'sanitize' the output for use in JSON, we only return debug
information if the user wants it. It is up to the user to use base64_encode()
to encode the data for json_encode().

Additionally, I moved the debug array keys into an array located in the 'debug'
array key.