Removed base64-stream dependency. Better error handling.