fixed error messages due to invalid graphics context

fixed error messages due to invalid graphics context (fixes #1)