Maybe try
function void image_file_read();
while ((read_char = $fgetc(input_file)) != -1)
begin
$display("%h",read_char);
$fwrite(output_file,read_char);
end
$fclose(input_file);
endfunction : image_file_read