fix image outputdirectory calculation and provide integration tests for embedding images in html + pdf.