tweak double-encode logic for image data

instead of only b64-encoding for valid image data,
b64-encode unless it is specifically detected as b64-encoded valid image data.
This prevents garbage data from skipping the b64 step,
and causing unicode errors.

Closes #3081
check image header to identify image type,

if only bytes are given.
allow Image("filename")
fix png/jpeg b64-encoding check
Merge pull request #3082 from minrk/image_garbage

A few small patches to image handling