Image upload urls add baseurl and media directory (if set)

This should fix #613 and #589.