Display images stored in a DB on canvas

I found the problem, I was saving the images on the DB using " MySQLdb.escape_string" and that was causing the problem. Now I’m saving the image in blob format whiout escape_string on the DB and the image is displayed using the same code I posted.