dec2hex returns a single 2d string which is then flattened by column into a 1d string in the call to fprintf. You have several options. one is to iterate over the rows of the 2d string and call fprintf on each row:
for hexrow = 1:size(imgHex, 1)
fprintf(fid, '%s\n', imgHex(hexrow, :));
end
Another is:
cellfun(@(hexstring) fprintf(fid, '%s\n', hexstring), num2cell(imgHex, 2));