I am not familiar with a matlab syntax k. format(fname)
.
If you want to do string formatting in Matlab - read this first.
A solution for your problem might be
outimage = fullfile( path2, sprintf('outimage_%03d_%s', k, fname ) );
EDIT:
following comment by OP, get the file format (tif):
[~, ~, ext] = fileparts(fname);
outimage = fullfile( path2, sprintf('outimage%d.%s',ext) );