Bugs and testing

Some bug fixes in SV code. Printing images to file for testing.