Added workaround for PHP Bug #39923 (undefined constant IMG_JPG)
Added workaround for PHP Bug #37268 (getting basename of the file with non-latin first letters)