Fix handling of relative paths

Image file was written at the wrong location.