generalized screenshot function