Enhances thumbail handling

I did the mistake of taking a look at the thumbnail code and simply couldn't help doing at least some refactoring to make it a bit less terrible:
 - Removes duplicate image handling code
 - Serves the images without loading the engine
 - Makes the code more readable

What do you think of the approach in ```image.php```?

BTW, we allow users to define ```access_id``` for the plugins, so should the images also respect it? I find it tempting to serve the images without checking the read access in ```image.php```.