factored out pyregion
fix ds9 script to use new mechanisms
minor refactoring and a sign error