To prevent the image from going off the right edge you need to compute the maximum value its x coordinate can have, and the make sure that value is never exceeded. So before the loop create a variable with the value in it:
CAT_RIGHT_LIMIT = WINDOWWIDTH - catImg.get_width()
And then in the loop check it:
if catx >= CAT_RIGHT_LIMIT:
moveRight = False
catx = CAT_RIGHT_LIMIT
if moveRight == True:
catx += 5
You can, of course, extend this idea to all the other edges.