Merge pull request #117 from sigurdm/fix_encoding_bugs

Fix problems in CodedBufferWriter 
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 059b317..e438523 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.9.1
+
+* Fix problem with encoding negative enum values.
+* Fix problem with encoding byte arrays.
+
 ## 0.9.0+1
 
 * Dart SDK upper constraint raised to declare compatability with Dart 2.0 stable.
diff --git a/lib/src/protobuf/coded_buffer_writer.dart b/lib/src/protobuf/coded_buffer_writer.dart
index 6a42262..0a36acf 100644
--- a/lib/src/protobuf/coded_buffer_writer.dart
+++ b/lib/src/protobuf/coded_buffer_writer.dart
@@ -317,7 +317,8 @@
         _writeVarint32(value ? 1 : 0);
         break;
       case PbFieldType._BYTES_BIT:
-        _writeBytesNoTag(value);
+        _writeBytesNoTag(
+            value is TypedData ? value : new Uint8List.fromList(value));
         break;
       case PbFieldType._STRING_BIT:
         _writeBytesNoTag(_utf8.encode(value));
@@ -329,7 +330,7 @@
         _writeFloat(value);
         break;
       case PbFieldType._ENUM_BIT:
-        _writeVarint32(value.value);
+        _writeVarint32(value.value & 0xffffffff);
         break;
       case PbFieldType._GROUP_BIT:
         value.writeToCodedBufferWriter(this);
diff --git a/pubspec.yaml b/pubspec.yaml
index f67a1f4..ee29bc8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: protobuf
-version: 0.9.0+1
+version: 0.9.1
 author: Dart Team <misc@dartlang.org>
 description: Runtime library for protocol buffers support.
 homepage: https://github.com/dart-lang/protobuf