fixes for encoding and image width