Fix Python 3.x issue with CloudTrail

This adds a test and fixes a bug with Python3 and the custom CloudTrail commands where a buffer was read but not decoded into a string before trying to replace values.

@jamesls please review.