Moved source window to MotionImagePlugin and added cleanup code