Fixed the segfault, the test image may not be working correctly though.