Escape filename

If the filename have special characters it may end up throwing an exception (for instance +1.png). Added preg_quote (borrowed from phpjs.org) to fix this issue