A "fringe" of colors that are not part of the image usually means that part of the image data has been replaced with other information. For example, if you load an image into an array -- say requiring 5100 elements, then load another image at the 5000 index, you have corrupted the last 100 elements of the first image. It can still be PUT since the width/depth information are intact, but those last 100 elements will be interpreted as nonsense -- to us, that is -- the computer thinks it's just fine. It can also happen if you BSAVE an image but save fewer bytes than make up the image. Once again, QBasic won't call you on it, but the results will be screwed up. I'm not sure how DIM'ing an array in a sub procedure would eliminate the problem. My guess is that you changed something else in the process that was causing the real problem.
-Bob