added misc functions for image manipulation