test image permission

This change adapts the tests to use the current working directory for image writing if the directory stated in the test code is not writable.  It also returns an error message if the stated directory in the tests and the current directory are both unable to be written to during image creation for testing