jpg-load: Fix infinite hang on http:// URIs due to missing _close()

Also fix leak and compile warnings
png-load: Fix a compile warning