Avoid throwing exceptions inside of glTexImage and other GL functions

These patches fix a problem with glGetError returning errors more than once in some cases, plus glTexImage* and glTexSubImage* will no longer throw exceptions when hitting unsupported formats, as per the GLES2 spec. A new test case has been added as well.