Clean up and improve updateXBMCTables.

The main improvement is special characters (quotes etc) are now properly,
encoded so they don't break JSON.