Corrected build output encoding problems.

Depend on charlock_holmes gem for encoding detection.
New Build#read_tmp_file method to correctly read the tmp file. This can
contain anything from the build process, so we cannot rely on
default_external encoding when we read in this file. We must read the
file, detect its encoding and convert it to utf-8 replacing invalid
sequences.
Build#compose_output was changed to call this new method.
Only read tmp_file if it's readable.
Sanitize build output before writing to database.

Build output must also be sanitized when writing to database. If the
database has connection encoding configured to utf-8 (as it should)
updating the trace attribute with non utf-8 data will cause an
exception in runner. This will leave the build in a stuck running
state, even if the process terminates some time after. This is a
separate bug that needs to be addressed in a different commit.
Merge branch 'master' of https://github.com/cabeca/gitlab-ci into cabeca-master

Conflicts:
	app/models/build.rb
Gemfile.lock
GitlabCi::Encode lib
Merge branch 'cabeca-master'