refactored function that returns a kernel image as std::string