I'm not sure what your code is doing, just what it's outputting, but I would suggest substituting spaces for something such as underscores, and using str_replace or your tool of choice to swap them in and out as needed.
my question remains unanswered, how did you get the DATA for the image? i dont want to see the end result, i was assuming that you either screen scraped or found an api from microsoft to grab the data thus my initial thought that it could be a problem in how you were requesting data from that web service.
edit: sorry if that sounds obnoxious, but i have a headache and tend to behave like a bear with a sore head xD
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)