Cleaned up the image profile subroutine

Rewrote and cleaned up the profile subroutines. Also organized
image.gsub better.