Oh, the code you posted is different than your first post. Can you spot the difference?

From #1:
Code:
ofs.put (width & 0xFF),  ofs.put ((width >> 8) & 0xFF);
From #4:
Code:
ofs.put (width & 0xFF), ofs.put ((width >> 8) & 0xFF00);
Besides that, I don't see any other issues. The Targa format takes 16-bit values for width and height, so you don't need bytes 3 and 4 (only bytes 0 and 1) of width and height.